import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';
import { queryParentIdTree, classByDepartment } from './StudentsInfo.api';
import { rules } from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
import { getWeekMonthQuarterYear } from '/@/utils';
// import { queryParentIdTree } from '@/api/common/api';
//列表数据
export const columns: BasicColumn[] = [
  /*  {
    title: '序号',
    align:"center",
    dataIndex: 'Id',
    width: 80,

   }, */
  {
    title: '学生姓名',
    align: 'center',
    dataIndex: 'studentName',
    width: 120,
  },
  {
    title: '学号',
    align: 'center',
    dataIndex: 'studentNumber',
    width: 100,
  },

  {
    title: '实验课班级',
    align: 'center',
    dataIndex: 'classNames',
    width: 120,
  },
  {
    title: '所属院系',
    align: 'center',
    dataIndex: 'departmentName',
    width: 130,
  },
  {
    title: '所属专业',
    align: 'center',
    dataIndex: 'majorName',
    width: 120,
  },
  /*  {
    title: '所属班级',
    align: 'center',
    dataIndex: 'classId',
    width: 200,
  }, */
];
//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    label: '学生姓名',
    field: 'studentName',
    component: 'JInput',
    colProps: { span: 4 },
    componentProps: {
      type: '',
    },
  },
  {
    label: '学生学号',
    field: 'studentId',
    component: 'JInput',
    colProps: { span: 4 },
    componentProps: {
      type: '',
    },
  },
  {
    label: '实验课班级',
    field: 'classId',
    component: 'ApiSelect',
    componentProps: {
      api: classByDepartment,
      labelField: 'className',
      valueField: 'id',
      immediate: false,
    },
    colProps: { span: 5 },
  },

  /*   {
    label: '所属院系',
    field: 'departmentId',
    colProps: { span: 5 },

    component: 'ApiSelect',
    componentProps: ({ formModel }) => {
      return {
        api: (params: any) => queryParentIdTree({ ...params, parentId: formModel.schoolId }),
        labelField: 'title',
        valueField: 'id',
        immediate: false,
      };
    },
  }, */
  /*   component: 'ApiSelect',
    componentProps: {
      
      api: getTeacherList,
      labelField: 'studentName',
      valueField: 'studentId',
      immediate: false,
    }, */
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '所属大学',
    field: 'schoolId',
    // show: false,
    required: true,
    component: 'ApiSelect',
    componentProps: {
      // mode: 'multiple',
      api: queryParentIdTree,
      labelField: 'title',
      valueField: 'id',
      immediate: false,
    },
  },
  {
    label: '所属院系',
    field: 'departmentId',

    // required: true,
    component: 'ApiSelect',
    componentProps: ({ formModel }) => {
      return {
        api: (params: any) => queryParentIdTree({ ...params, parentId: formModel.schoolId }),
        labelField: 'title',
        valueField: 'id',
        immediate: false,
      };
    },
  },
  {
    label: '所属专业',
    field: 'majorId',

    required: true,
    component: 'ApiSelect',
    componentProps: ({ formModel }) => {
      return {
        api: (params: any) => queryParentIdTree({ ...params, parentId: formModel.departmentId }),
        labelField: 'title',
        valueField: 'id',
        immediate: false,
      };
    },
  },
  /* {
    label: '所属院校',
    field: 'selectdeparts',
    component: 'JSelectDept',
    componentProps: ({ formActionType, formModel }) => {
      return {
        sync: false,
        checkStrictly: true,
        defaultExpandLevel: 2,

        onSelect: (options, values) => {
          const { updateSchema } = formActionType;
          //所属部门修改后更新负责部门下拉框数据
          updateSchema([
            {
              field: 'departIds',
              componentProps: { options },
            },
          ]);
          //update-begin---author:wangshuai---date:2024-05-11---for:【issues/1222】用户编辑界面“所属部门”与“负责部门”联动出错整---
          if (!values) {
            formModel.departIds = [];
            return;
          }
          //update-end---author:wangshuai---date:2024-05-11---for:【issues/1222】用户编辑界面“所属部门”与“负责部门”联动出错整---
          //所属部门修改后更新负责部门数据
          formModel.departIds && (formModel.departIds = formModel.departIds.filter((item) => values.value.indexOf(item) > -1));
        },
      };
    },
    required: true,
  }, */
  /* {
    label: '入学时间',
    field: 'entryTime',
    component: 'Input',
    required: true,
  }, */
  {
    label: '学生学号',
    field: 'studentNumber',
    component: 'Input',
    required: true,
  },
  {
    label: '学生姓名',
    field: 'studentName',
    component: 'Input',
    required: true,
  },
  {
    label: '登录账号',
    field: 'studentNumber',
    component: 'Input',
    required: true,
  },
  {
    label: '所属实验课班级',
    field: 'classNames',
    component: 'ApiSelect',
    componentProps: {
      api: classByDepartment,
      labelField: 'className',
      valueField: 'id',
      immediate: false,
    },

    required: true,
  },
  // TODO 主键隐藏字段，目前写死为ID
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false,
  },
];

// 高级查询数据
export const superQuerySchema = {
  departmentId: { title: '院校主键', order: 0, view: 'text', type: 'string' },
  collegesId: { title: '院系主键', order: 1, view: 'text', type: 'string' },
  majorId: { title: '专业主键', order: 2, view: 'text', type: 'string' },
  studentNumber: { title: '学号', order: 3, view: 'text', type: 'string' },
  studentName: { title: '学生姓名', order: 4, view: 'text', type: 'string' },
};

/**
 * 流程表单调用这个方法获取formSchema
 * @param param
 */
export function getBpmFormSchema(_formData): FormSchema[] {
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}
